package com.ts.code.creator.creator.impl;

import com.ts.code.creator.enums.CreateFileEnum;
import com.ts.code.creator.express.ExpressContext;
import com.ts.code.creator.express.ExpressUtil;
import com.ts.code.creator.util.CreateCodeContext;
import com.ts.code.creator.util.StringUtil;

/**
 * 聚合层 controller
 */
public class ServiceServiceCreator extends AbstractCodeCreator {

    public ServiceServiceCreator(CreateCodeContext context) {
        super(context);
    }

    @Override
    protected CreateFileEnum createFileEnum() {
        return CreateFileEnum.SERVICE_SERVICE;
    }

    @Override
    public void doCreate() {
        // 服务层 service
        addMethod(classFileSearch.serviceService(), serviceService(context));
    }

    private String serviceService(CreateCodeContext context) {
        // /**
        //     * 查询福利状态
        //     * @param reqDTO 请求参数
        //     * @return 结果
        //     */
        //    WelfareQueryStatusRespDTO queryStatus(IdsReqDTO reqDTO);

        String text = remark("reqDTO") +
                "    ${respDTO} ${methodName}(${serviceParamStr});";

        String reqDTO = reqDTO();
        ExpressContext expressContext = new ExpressContext();
        expressContext.put(context);
        expressContext.put("respDTO", respDTO());
        expressContext.put("returnType", adminVO());
        expressContext.put("serviceParamStr", reqDTO);
        expressContext.put("entityNameLower", StringUtil.firstLower(context.getEntityName()));
        expressContext.put("reqDTO", StringUtil.isNotBlank(reqDTO) ? "reqDTO" : "");
        return ExpressUtil.eval(text, expressContext);
    }

}
